package ch.fusun.baron.basic.command;

import ch.fusun.baron.core.command.GameCommand;
import ch.fusun.baron.core.injection.Inject;
import ch.fusun.baron.player.Player;
import ch.fusun.baron.player.api.MarriageService;

/**
 * Proposes a marriage between two {@link Player}s
 */
public class ProposeMarriageCommand extends GameCommand {

	private transient Player proposer;
	private transient Player proposedTo;

	@Inject
	MarriageService marriageService;

	/**
	 * Kryo Constructor
	 */
	public ProposeMarriageCommand() {
	}

	/**
	 * @param proposer
	 *            The husband
	 * @param proposedTo
	 *            The bride
	 */
	public ProposeMarriageCommand(Player proposer, Player proposedTo) {
		this.proposer = proposer;
		this.proposedTo = proposedTo;
	}

	@Override
	public boolean isAllowed() {
		return this.proposer != null
				&& this.proposedTo != null
				&& !this.proposedTo.getGender().equals(
						this.proposer.getGender());
	}

	@Override
	public void execute() {
		marriageService.proposeMarriage(proposer, proposedTo);
	}
}
